﻿using System;
using System.Text;
using System.Drawing;
using System.Buffers;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;

public static partial class NativeAOT
{
    [UnmanagedCallersOnly(EntryPoint = "errf")]
    public static unsafe double errf_dll(double x)
    {
        return errf(x);
    }

    /// <summary>
    /// 误差函数
    /// </summary>
    /// <param name="x">自变量值。</param>
    /// <returns>函数返回误差函数值。</returns>
    public static unsafe double errf(double x)
    {
        double y;
        if (x >= 0.0) y = ingamma(0.5, x * x);
        else y = -ingamma(0.5, x * x);
        return (y);
    }

    /*
    // 误差函数例
      int main()
      { 
          int i,j;
          double x,y;
          x = 0.0;  y = errf(x);
          cout <<setw(15) <<y <<endl;
          for (i=0; i<=7; i++)
          { 
              for (j=0; j<=4; j++)
              { 
                  x = x + 0.05;   y=errf(x);
                  cout <<setw(15) <<y;
              }
              cout <<endl;
          }
          return 0;
      }
    */
}

